package com.titanrise.crm.environment.orm;

import com.titanrise.crm.environment.ioc.SingletonPoolUtil;

import java.lang.reflect.Proxy;

public class MapperFactory {
    @SuppressWarnings("unchecked")
    public static <T> T getMapper(Class<T> mapperInterface) {
        ClassLoader classLoader = mapperInterface.getClassLoader();
        Class<?>[] classes = {mapperInterface};
        MapperProxy bean = SingletonPoolUtil.getBean(MapperProxy.class);
        return (T) Proxy.newProxyInstance(classLoader, classes, bean);
    }
}
